我有一个python脚本说"foo_1.py"位于文件夹x中,另一个脚本foo_2.py位于文件夹y中.
文件夹x和y位于文件夹z中.
我调用了一个属于foo_2.py的方法,它在文件夹y中生成一个图像(比如img1.png).现在我想要的是从foo_1.py访问这个img1.png.这怎么可能?
我使用python中的postgresql更新了数据库表我的代码是
import psycopg2
connection=psycopg2.connect("dbname=homedb user=ria")
cursor=connection.cursor()
l_dict= {'licence_id':1}
cursor.execute("SELECT * FROM im_entry.usr_table")
rows=cursor.fetchall()
for row in rows:
i=i+1
p = findmax(row)
#print p
idn="id"
idn=idn+str(i)
cursor.execute("UPDATE im_entry.pr_table SET (selected_entry) = ('"+p+"') WHERE image_1d ='"+idn+"'")
print 'DATABASE TO PRINT'
cursor.execute("SELECT * FROM im_entry.pr_table")
rows=cursor.fetchall()
for row in rows:
print row
Run Code Online (Sandbox Code Playgroud)
我显示了更新的表格
但当我通过psql显示更新的表作为homedb =#SELECT*FROM im_entry.pr_table; 我显示了一个空表...有什么不对?请帮我
entrym='entry'
entrym=entrym+ str(idx)
cursor.execute("INSERT INTO im_entry.test ("+entrym+") VALUES ('"+p+"');")
Run Code Online (Sandbox Code Playgroud)
我正在使用这样的查询,其中entry1,entry2等等是我的数据库表.该程序不显示任何错误,但该p值不会插入数据库中.这有什么不对?请帮我.
我刚开始使用python ..我的for循环出错了.问题是什么?
Traceback (most recent call last):
File "userentry.py", line 34, in <module>
userentry(p,i)
File "userentry.py", line 26, in userentry
for cl in len(mylist):
TypeError: 'int' object is not iterable
Run Code Online (Sandbox Code Playgroud)
请帮我