Code: Alles auswählen
michi@sys-hier-in-kiel ~ $ python3
Python 3.5.4 (default, Dec 5 2017, 16:48:10)
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> str = "this is string example....wow!!! this is really string"
>>> print str.replace("is", "was")
File "<stdin>", line 1
print str.replace("is", "was")
^
SyntaxError: invalid syntax
>>> print str.replace("is", "was")
File "<stdin>", line 1
print str.replace("is", "was")
^
SyntaxError: invalid syntax
>>> print str.replace("is", "was")
File "<stdin>", line 1
print str.replace("is", "was")
^
SyntaxError: invalid syntax
>>> print str.replace
File "<stdin>", line 1
print str.replace
^
SyntaxError: Missing parentheses in call to 'print'
>>> print str.replace("is")
File "<stdin>", line 1
print str.replace("is")
^
SyntaxError: invalid syntax
>>> str = "test"
>>> print str.replace("is")
File "<stdin>", line 1
print str.replace("is")
Example
The following example shows the usage of replace() method.
#!/usr/bin/python
str = "this is string example....wow!!! this is really string"
print str.replace("is", "was")
print str.replace("is", "was", 3)
Ich verwende Python3. Soweit ich das sehe ist der Code doch Phyton3 (?) . Ist ein Fehler im Code den ich übersehen habe? Oder was kann die Ursache sein?