简体   繁体   English

打印语句中的end关键字在Python UBUNTU中不起作用

[英]End keyword in print statement is not working in Python UBUNTU

The end keyword used with print statement is not working in my PYTHON UBUNTU(neither in sublime nor in pycharm ce nor in terminal. Not even by importing sys and time 与print语句一起使用的end关键字在我的PYTHON UBUNTU中不起作用(无论是在sublime还是在pycharm ce中,也没有在终端中。甚至都无法导入sys和time

I tried importing sys and time and using time.sleep(),sys.stdout.write(), sys.stdout.flush() too 我也尝试导入sys和时间并使用time.sleep(),sys.stdout.write(),sys.stdout.flush()

This Is the Code 这是代码

print("Hi",end=" ")
print("hello")

Error Message: 错误信息:

file "/home/ansh/Desktop/fun.py", line 3
print("Hello", end = " ")
                    ^
SyntaxError: invalid syntax
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/home/ansh/Desktop/fun.py"]
[dir: /home/ansh/Desktop]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:                /bin:/usr/games:/usr/local/games:/snap/bin]

Looks like you're using Python 2.x instead of 3.x. 看起来您正在使用Python 2.x而不是3.x。

The same thing can be achieved in Python 2.x with this: 在Python 2.x中可以使用以下方法实现相同的目的:

print "Hi", 
print "hello"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM