关于Pypy有一些问题,请高手进来解答
时间:2011-09-12
来源:互联网
本人菜鸟一枚,以下代码是在朋友的帮助下完成的,运行的时候总是提示typeerror:an integer is required,看了半天也没看出什么问题,请各位大虾帮忙看看是什么情况,小女子在此先谢过各位了。dbgpy的链接:http://dbfpy.sourceforge.net/
代码:
#!/usr/local/bin/python
import sys
import os
import datetime
import string
from dbfpy import dbf
#from mx import DateTime
def usage():
print "%s inputfile " % sys.argv[0]
def dbf_init(station, line):
cmd = 'mkdir -p ' + station
os.system(cmd)
for i in range(1,16):
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
db = dbf.Dbf(filename, new=True)
db.addField(
("DATE", "D"),
("VALUE", "N", 18),
)
db.close()
dbf_update(station, line)
return 0
def dbf_update(station, line):
for i in range(1,16):
column = i+3
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
# time = line[3]+'/'+line[2]+'/'+line[1]
time = (line[1], line[2], line[3])
value = string.atoi(line[column])
db = dbf.Dbf(filename)
rec = db.newRecord()
rec["DATE"] = time
rec["VALUE"] = value
rec.store()
db.close()
return 0
if len(sys.argv) is not 2:
usage()
sys.exit(1)
file = sys.argv[1]
station_hash = {}
fp = open(file , 'r')
for eachline in fp:
line = eachline.split(' ')
station = line[0]
if( station_hash.has_key(station) ):
station_hash[station] += 1
# print "has key"
# print station_hash[station]
dbf_update(station, line)
else:
station_hash[station] = 1
print station
dbf_init(station, line)
#db = dbf.Dbf("test.dbf", new=True)
#db.addField(
# ("DATE", "D", 9),
# ("VALUE", "N", 25),
#)
#print db
#
#for i in range(1,5):
# rec = db.newRecord()
# rec["DATE"] = "01-01-2011"
# rec["VALUE"] = 4000
# rec.store()
#db.close()
最后由 piggy527 编辑于 2011-09-12 14:39,总共编辑了 1 次
代码:
#!/usr/local/bin/python
import sys
import os
import datetime
import string
from dbfpy import dbf
#from mx import DateTime
def usage():
print "%s inputfile " % sys.argv[0]
def dbf_init(station, line):
cmd = 'mkdir -p ' + station
os.system(cmd)
for i in range(1,16):
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
db = dbf.Dbf(filename, new=True)
db.addField(
("DATE", "D"),
("VALUE", "N", 18),
)
db.close()
dbf_update(station, line)
return 0
def dbf_update(station, line):
for i in range(1,16):
column = i+3
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
# time = line[3]+'/'+line[2]+'/'+line[1]
time = (line[1], line[2], line[3])
value = string.atoi(line[column])
db = dbf.Dbf(filename)
rec = db.newRecord()
rec["DATE"] = time
rec["VALUE"] = value
rec.store()
db.close()
return 0
if len(sys.argv) is not 2:
usage()
sys.exit(1)
file = sys.argv[1]
station_hash = {}
fp = open(file , 'r')
for eachline in fp:
line = eachline.split(' ')
station = line[0]
if( station_hash.has_key(station) ):
station_hash[station] += 1
# print "has key"
# print station_hash[station]
dbf_update(station, line)
else:
station_hash[station] = 1
print station
dbf_init(station, line)
#db = dbf.Dbf("test.dbf", new=True)
#db.addField(
# ("DATE", "D", 9),
# ("VALUE", "N", 25),
#)
#print db
#
#for i in range(1,5):
# rec = db.newRecord()
# rec["DATE"] = "01-01-2011"
# rec["VALUE"] = 4000
# rec.store()
#db.close()
附件: |
tangyin_new.py [1.58 KiB] 被下载 1 次 |
最后由 piggy527 编辑于 2011-09-12 14:39,总共编辑了 1 次
作者: piggy527 发布时间: 2011-09-12
你至少应该附上dbfpy,没人会去查你之前的帖子
作者: tenzu 发布时间: 2011-09-12
本人菜鸟一枚,以下代码是在朋友的帮助下完成的,运行的时候总是提示typeerror:an integer is required,看了半天也没看出什么问题,请各位大虾帮忙看看是什么情况,小女子在此先谢过各位了。dbgpy的链接:http://dbfpy.sourceforge.net/
代码:
#!/usr/local/bin/python
import sys
import os
import datetime
import string
from dbfpy import dbf
#from mx import DateTime
def usage():
print "%s inputfile " % sys.argv[0]
def dbf_init(station, line):
cmd = 'mkdir -p ' + station
os.system(cmd)
for i in range(1,16):
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
db = dbf.Dbf(filename, new=True)
db.addField(
("DATE", "D"),
("VALUE", "N", 18),
)
db.close()
dbf_update(station, line)
return 0
def dbf_update(station, line):
for i in range(1,16):
column = i+3
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
# time = line[3]+'/'+line[2]+'/'+line[1]
time = (line[1], line[2], line[3])
value = string.atoi(line[column])
db = dbf.Dbf(filename)
rec = db.newRecord()
rec["DATE"] = time
rec["VALUE"] = value
rec.store()
db.close()
return 0
if len(sys.argv) is not 2:
usage()
sys.exit(1)
file = sys.argv[1]
station_hash = {}
fp = open(file , 'r')
for eachline in fp:
line = eachline.split(' ')
station = line[0]
if( station_hash.has_key(station) ):
station_hash[station] += 1
# print "has key"
# print station_hash[station]
dbf_update(station, line)
else:
station_hash[station] = 1
print station
dbf_init(station, line)
#db = dbf.Dbf("test.dbf", new=True)
#db.addField(
# ("DATE", "D", 9),
# ("VALUE", "N", 25),
#)
#print db
#
#for i in range(1,5):
# rec = db.newRecord()
# rec["DATE"] = "01-01-2011"
# rec["VALUE"] = 4000
# rec.store()
#db.close()
最后由 piggy527 编辑于 2011-09-12 14:39,总共编辑了 1 次
代码:
#!/usr/local/bin/python
import sys
import os
import datetime
import string
from dbfpy import dbf
#from mx import DateTime
def usage():
print "%s inputfile " % sys.argv[0]
def dbf_init(station, line):
cmd = 'mkdir -p ' + station
os.system(cmd)
for i in range(1,16):
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
db = dbf.Dbf(filename, new=True)
db.addField(
("DATE", "D"),
("VALUE", "N", 18),
)
db.close()
dbf_update(station, line)
return 0
def dbf_update(station, line):
for i in range(1,16):
column = i+3
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
# time = line[3]+'/'+line[2]+'/'+line[1]
time = (line[1], line[2], line[3])
value = string.atoi(line[column])
db = dbf.Dbf(filename)
rec = db.newRecord()
rec["DATE"] = time
rec["VALUE"] = value
rec.store()
db.close()
return 0
if len(sys.argv) is not 2:
usage()
sys.exit(1)
file = sys.argv[1]
station_hash = {}
fp = open(file , 'r')
for eachline in fp:
line = eachline.split(' ')
station = line[0]
if( station_hash.has_key(station) ):
station_hash[station] += 1
# print "has key"
# print station_hash[station]
dbf_update(station, line)
else:
station_hash[station] = 1
print station
dbf_init(station, line)
#db = dbf.Dbf("test.dbf", new=True)
#db.addField(
# ("DATE", "D", 9),
# ("VALUE", "N", 25),
#)
#print db
#
#for i in range(1,5):
# rec = db.newRecord()
# rec["DATE"] = "01-01-2011"
# rec["VALUE"] = 4000
# rec.store()
#db.close()
附件: |
tangyin_new.py [1.58 KiB] 被下载 1 次 |
最后由 piggy527 编辑于 2011-09-12 14:39,总共编辑了 1 次
作者: piggy527 发布时间: 2011-09-12
你至少应该附上dbfpy,没人会去查你之前的帖子
作者: tenzu 发布时间: 2011-09-12
本人菜鸟一枚,以下代码是在朋友的帮助下完成的,运行的时候总是提示typeerror:an integer is required,看了半天也没看出什么问题,请各位大虾帮忙看看是什么情况,小女子在此先谢过各位了。dbgpy的链接:http://dbfpy.sourceforge.net/
代码:
#!/usr/local/bin/python
import sys
import os
import datetime
import string
from dbfpy import dbf
#from mx import DateTime
def usage():
print "%s inputfile " % sys.argv[0]
def dbf_init(station, line):
cmd = 'mkdir -p ' + station
os.system(cmd)
for i in range(1,16):
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
db = dbf.Dbf(filename, new=True)
db.addField(
("DATE", "D"),
("VALUE", "N", 18),
)
db.close()
dbf_update(station, line)
return 0
def dbf_update(station, line):
for i in range(1,16):
column = i+3
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
# time = line[3]+'/'+line[2]+'/'+line[1]
time = (line[1], line[2], line[3])
value = string.atoi(line[column])
db = dbf.Dbf(filename)
rec = db.newRecord()
rec["DATE"] = time
rec["VALUE"] = value
rec.store()
db.close()
return 0
if len(sys.argv) is not 2:
usage()
sys.exit(1)
file = sys.argv[1]
station_hash = {}
fp = open(file , 'r')
for eachline in fp:
line = eachline.split(' ')
station = line[0]
if( station_hash.has_key(station) ):
station_hash[station] += 1
# print "has key"
# print station_hash[station]
dbf_update(station, line)
else:
station_hash[station] = 1
print station
dbf_init(station, line)
#db = dbf.Dbf("test.dbf", new=True)
#db.addField(
# ("DATE", "D", 9),
# ("VALUE", "N", 25),
#)
#print db
#
#for i in range(1,5):
# rec = db.newRecord()
# rec["DATE"] = "01-01-2011"
# rec["VALUE"] = 4000
# rec.store()
#db.close()
最后由 piggy527 编辑于 2011-09-12 14:39,总共编辑了 1 次
代码:
#!/usr/local/bin/python
import sys
import os
import datetime
import string
from dbfpy import dbf
#from mx import DateTime
def usage():
print "%s inputfile " % sys.argv[0]
def dbf_init(station, line):
cmd = 'mkdir -p ' + station
os.system(cmd)
for i in range(1,16):
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
db = dbf.Dbf(filename, new=True)
db.addField(
("DATE", "D"),
("VALUE", "N", 18),
)
db.close()
dbf_update(station, line)
return 0
def dbf_update(station, line):
for i in range(1,16):
column = i+3
index = str(i)
filename = station + '/' + station + '_' + index + '.dbf'
# time = line[3]+'/'+line[2]+'/'+line[1]
time = (line[1], line[2], line[3])
value = string.atoi(line[column])
db = dbf.Dbf(filename)
rec = db.newRecord()
rec["DATE"] = time
rec["VALUE"] = value
rec.store()
db.close()
return 0
if len(sys.argv) is not 2:
usage()
sys.exit(1)
file = sys.argv[1]
station_hash = {}
fp = open(file , 'r')
for eachline in fp:
line = eachline.split(' ')
station = line[0]
if( station_hash.has_key(station) ):
station_hash[station] += 1
# print "has key"
# print station_hash[station]
dbf_update(station, line)
else:
station_hash[station] = 1
print station
dbf_init(station, line)
#db = dbf.Dbf("test.dbf", new=True)
#db.addField(
# ("DATE", "D", 9),
# ("VALUE", "N", 25),
#)
#print db
#
#for i in range(1,5):
# rec = db.newRecord()
# rec["DATE"] = "01-01-2011"
# rec["VALUE"] = 4000
# rec.store()
#db.close()
附件: |
tangyin_new.py [1.58 KiB] 被下载 1 次 |
最后由 piggy527 编辑于 2011-09-12 14:39,总共编辑了 1 次
作者: piggy527 发布时间: 2011-09-12
你至少应该附上dbfpy,没人会去查你之前的帖子
作者: tenzu 发布时间: 2011-09-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28