小编Rya*_*ner的帖子

在尝试使用asin()时未定义名称'math'时出错

我已经制作了一个Trignometric计算器(种类 - 它只使用现在的正弦比),但我不能让它正常工作.我得到一个错误,表示数学未定义时应该得到该行的长度.这是我的代码:

    trig = raw_input ('What are you looking for? A) I have the opposite, and I want the        Hypotenuse. ')
    if trig.lower() == 'a':
        ang = raw_input ('Please enter the measure of the angle you have ')
        line = raw_input ('Please enter the length of the opposite! ')
        math.asin (ang)*line
Run Code Online (Sandbox Code Playgroud)

python

4
推荐指数
1
解决办法
3676
查看次数

使用 PYTTSX 时随机出现 EOFError 并且我的代码现在不断抛出此错误?它在几个小时前运行良好

我昨天在使用 PYTTSX 没有任何问题 - 它的行为完全符合预期并且工作正常。但是,当我在不到两个小时后尝试运行完全相同的代码时,它抛出了这个错误:

Traceback (most recent call last):
  File "C:\Python27\FUCK.py", line 2, in <module>
    engine = pyttsx.init()
  File "C:\Python27\lib\site-packages\pyttsx\__init__.py", line 39, in init
    eng = Engine(driverName, debug)
  File "C:\Python27\lib\site-packages\pyttsx\engine.py", line 45, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  File "C:\Python27\lib\site-packages\pyttsx\driver.py", line 64, in __init__
    self._module = __import__(name, globals(), locals(), [driverName])
  File "C:\Python27\lib\site-packages\pyttsx\drivers\sapi5.py", line 19, in <module>
    import win32com.client
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 11, in <module>
    import gencache
  File "C:\Python27\lib\site-packages\win32com\client\gencache.py", line 662, in <module>
__init__()
  File "C:\Python27\lib\site-packages\win32com\client\gencache.py", line 56, in …
Run Code Online (Sandbox Code Playgroud)

python eoferror python-2.7 pyttsx

4
推荐指数
1
解决办法
657
查看次数

如何在Python脚本中的段落之间创建空格?

我正在使用Python制作一个游戏(仅限文本),但是当人们播放它时会让人感到困惑,因为段落之间没有空格,所以它看起来像这样:

'You step outside and feel the wind on your face.'
'Which direction do you turn?'
Run Code Online (Sandbox Code Playgroud)

但我希望它看起来像这样:

'You step outside and feel the breeze on your face'

'What do you do next'?
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

print 'You step outside and feel the cool breeze on your face.'
what = raw_input ('What do you do next ')
Run Code Online (Sandbox Code Playgroud)

谢谢!

python paragraph

1
推荐指数
1
解决办法
4万
查看次数

在Python中管理用户输入的案例

当用户输入其他内容时,我已经设置了一个脚本来说出一些内容Yes.然而,当用户说时,它仍然会这样说Yes.我究竟做错了什么?

我使用的是Python 2.7.2.
这是我的代码:

print 'Hi! Welcome!'
begin = raw_input ('Will you answer some questions for me? ')
if begin == 'yes':
    print 'Ok! Let\'s get started then!'
else:
    print 'Well then why did you open a script clearly entiled\'QUIZ\'?!'
Run Code Online (Sandbox Code Playgroud)

python case-sensitive

-1
推荐指数
2
解决办法
1万
查看次数