我正在尝试使用 lua 生成一个随机数,但它只是吐出最低值。例如,如果我运行:
x = math.random(17,41)
print(x)
Run Code Online (Sandbox Code Playgroud)
它返回:
17
Run Code Online (Sandbox Code Playgroud)
怎么了?
我想用python下载一个大型存档文件并保存它,但是urllib对我不起作用.这是我的代码:
import urllib
urllib.request("http://www.petercollingridge.co.uk/sites/files/peter/particle_tutorial_7.txt")
Run Code Online (Sandbox Code Playgroud)
请注意,我在此示例中使用的链接不是大型存档.我只是以它为例.它直接链接到.txt文件,因此它应该工作.我收到此错误:
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
urllib.request("http://www.petercollingridge.co.uk/sites/files/peter/particle_tutorial_7.txt")
AttributeError: 'module' object has no attribute 'request'
Run Code Online (Sandbox Code Playgroud)
在我看来,urllib在某种程度上被打破并缺少"请求"方法.我使用的是Python 3.3.我应该使用其他模块还是实际上是Python问题?
我最近被朋友要求帮助在lua写一个程序找到完美的正方形,所以我拟定了这个:
print ("Select your maximum number")
x = io.read()
y=1
z={}
a=1
while y * y ~= x and y < x / 2
then do
y = y + 1
end
if y * y = x
then do
z[a] = x
a = a + 1
end
x = x - 1
Run Code Online (Sandbox Code Playgroud)
为了测试这个程序,我补充道
print z[1]
Run Code Online (Sandbox Code Playgroud)
到最后.当我去测试这个程序时,我在第8行得到了以下错误:
预计在那附近
就在那附近.有人能告诉我哪里出错了吗?谢谢.