在SageMath中使用Python输入文本
下面是我用Python尝试的代码
>>> import string
>>> def main():
print "hey"
print
key = input ("key?")
message = raw_input("Enter the message: ")
codedMessage = ""
for ch in message:
codedMessage = codedMessage + chr(ord(ch) + key)
print "the coded is: ", codedMessage
>>> main()
hey
key?-1
Enter the message: hey how are you?
the coded is: gdx gnv `qd xnt>
但是当我在Sage Math中试这个的时候……输入功能不管用
2 个回答
0
raw_input
在Sage Math Cloud中确实可以用,不过现在有些奇怪的地方(具体可以查看这个链接:https://github.com/sagemathinc/smc/issues/358)。看起来还不错。
1
很遗憾,根据我所知道的,虽然在控制台模式下,input和raw_input在Sage中可以正常使用,但在Sage笔记本中这两个都无法使用(你没有具体说明,但我假设你是在用这个)。