在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/ Python問答
故林 回答

async await了解一下 典型異步了

心夠野 回答

class TempDataFileCanIter(object):

"""
將文件對(duì)象封裝成迭代器
"""
def __init__(self, tempDataFilePath):
    self.tDFile = open(tempDataFilePath, "r")
    
def __iter__(self):
    return self
    
def next(self):
    try:
        for line in self.tDFile:
            return line.rstrip()
        raise StopIteration()
    except StopIteration:
        self.tDFile.close()
        raise StopIteration()
    except BaseException, ex:
        self.tDFile.close()
        raise Exception(ex)
        
***def __def__(self):
    self.tDFile.close()***

自己在類中加了個(gè)析構(gòu)函數(shù)。所以只要在某個(gè)函數(shù)作用域中生成該類實(shí)例對(duì)象和使用,并且最后這個(gè)函數(shù)結(jié)束,那么對(duì)象的析構(gòu)函數(shù)就被調(diào)用就可以保證關(guān)閉文件(其他不會(huì)關(guān)閉的情況我也想不到了)。其實(shí)我一般都是用with的,就是項(xiàng)目比較特殊with不滿足。
感謝@yszou 的回答。

瘋子范 回答

原文不就是這個(gè)字符嗎?

款爺 回答

依錯(cuò)誤信息來看,這一行

image_file_path = value["path"]

有問題,因?yàn)?value 變量是 listtuple。

乖乖噠 回答

add 'r' in front of address, like this (r'C:....')

陌顏 回答

我是直接編輯 /etc/paths,把 /usr/local/anaconda3/bin 加進(jìn)去。
看這個(gè):Get your anaconda ready with brew install

誮惜顏 回答

如果你報(bào)的錯(cuò)是這個(gè)

 Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))
 after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.or
g', port=443): Read timed out. (read timeout=15)",)': /simple/mysqldb/
  Could not find a version that satisfies the requirement MySQLdb (from versions
: )

你可以嘗試加大超時(shí)時(shí)間

pip --default-timeout=100 install MySQLdb

個(gè)人建議換源(清華),速度也會(huì)加快

pip install --index https://mirrors.ustc.edu.cn/pypi/web/simple/ virtualenv 
忘了我 回答

1

for i in open('score.txt', 'r'):

list1=i.split()
tuple1=tuple(list1)
print(tuple1)

2

open_tmp=open('score.txt', 'r')
key_tmp=open_tmp.readline()
key1=key_tmp.split()
stu_info = []
for i2 in open_tmp:

key2=i2.split()
zip_put=dict(zip(key1,key2))
stu_info.append(zip_put)

3

def three():

score = []
m_score = []
f_score = []
for dct in stu_info:
    sco = dct['score']
    score.append(sco)
    if dct['sex'] == 'm':
        sc_m = dct['score']
        m_score.append(sc_m)
    if dct['sex'] == 'f':
        sc_f = dct['score']
        f_score.append(sc_f)

# 最高分學(xué)生
for stu in stu_info:
    if stu['score'] == max(score):
        print(stu)
# 最低分學(xué)生
for stu in stu_info:
    if stu['score'] == min(score):
        print(stu)

def avg(score):
    sum = 0
    for i in score:
        sum += int(i)
    avg = sum/len(score)
    return avg
# 平均分
print(avg(score))
print(avg(m_score))
print(avg(f_score))

three()

4

def four():

# 編輯
with open("score.txt","r",encoding="utf-8") as f:
    lines = f.readlines()
with open("score.txt","w",encoding="utf-8") as f_w:
    for line in lines:
        if "舊內(nèi)容" in line:
            line = line.replace("舊內(nèi)容", '新內(nèi)容')
        f_w.write(line)
# 增加
with open("score.txt","r",encoding="utf-8") as f:
    lines = f.readlines()
with open("score.txt","w",encoding="utf-8") as f_w:
    f_w.write('新增內(nèi)容')

# 刪除信息
with open("score.txt","r",encoding="utf-8") as f:
    lines = f.readlines()
with open("score.txt","w",encoding="utf-8") as f_w:
    for line in lines:
        if "你要?jiǎng)h的學(xué)生" in line:
            continue
        f_w.write(line)

four()

舊顏 回答

mysql可以使用 Spatial 空間數(shù)據(jù)類型, 里面有點(diǎn),線,面. 一個(gè)字段就能保存, 不需要建表.

https://dev.mysql.com/doc/ref...

嘟尛嘴 回答

因?yàn)?$"是一個(gè)特殊字符,具體看replace

默念 回答

requests.get是requests庫(第三方庫)的get請(qǐng)求, 參考http://docs.python-requests.o...
urllib2.Request是urllib2庫(官方庫)的請(qǐng)求,既可以是get也可以是post 參考https://docs.python.org/2.7/l...

使勁操 回答

這是js中作用域的問題跟vue沒關(guān)系,在學(xué)vue之前還是要好好的了解下js原理。建議去看看js權(quán)威指南。

苦妄 回答

python 2.7里print是語句:

print "hello world"

python 3.x里print是函數(shù):

print("hello world")
安淺陌 回答

from ..models import User 試試

尤禮 回答

老哥首先你的SID沒有問題 ,排查思路:

  1. 你檢查的是你的tnsname.ora,這個(gè);連接文件 ,然后測(cè)試 在cmd 里正常用監(jiān)聽登錄是否可以登錄

2.我是昨天研究的 ,你的pandas 學(xué)習(xí)了 pd.read_sql(sql,conn) 這個(gè)寫法待驗(yàn)證 ,是我get 到的點(diǎn)

3.我遇到的問題是在ubuntu用pycharm里寫代碼無法連接oracle數(shù)據(jù)庫 ,但pycharm 自帶的工具可以連接,在shell里也可以正常連接 最后也沒有找到原因 一直報(bào)錯(cuò)說是不是64位客戶端 ,但我所有的包都是64位的,待解決。。。

4.最后附上干貨,我的連接demo 以及將數(shù)據(jù)寫入到csv文件,僅供參考,老哥記得回復(fù)我,維護(hù)社區(qū)秩序。。

#!/usr/bin/python

import cx_Oracle as oracle
import csv
def oraclesql(cursor):
   #fp = open('D:/1.sql')
   #fp_sql = fp.read()
   cursor.execute("select * from emp")
   data = cursor.fetchall()
   #print (list(data))
   return list(data)
def write_to_csv(content):
    with open('oracle.csv','a') as csvfile:
        filename = ['empno','ename','job','mgr','hiredate','sal','comm','deptno']
        #filename = ['LOTS','ORG_ID','YEAR_TIME','NAME_PATIENT','GENDER','BIRTHDAY','AGE','RESIDENT_ID','HUKOU_ADDRESS']
        write = csv.writer(csvfile,delimiter=',')
        # write.writeheader()
        
        write.writerows([content])

 
 
if __name__ == '__main__':
   ipaddr = "127.0.0.1"
   username = "scott"
   password = "scott"
   oracle_port = "1521"
   oracle_service = "orcl"
   try:
      db = oracle.connect(username+"/"+password+"@"+ipaddr+":"+oracle_port+"/"+oracle_service)
    # 將異常捕捉
   except Exception as e:  
      print(e)
   else:
      cursor = db.cursor()
      data = oraclesql(cursor)
      for i in data:
          text = list(i)
          #print(text)
          write_to_csv(text)
      cursor.close()
      db.close()
      
礙你眼 回答

ret.status_code == requests.codes.ok
http://www.python-requests.or...
你傳的url是https的就是https不可能是http,請(qǐng)求的端口都不一樣,http是80,https是443
ret.text是你獲取的內(nèi)容,如果內(nèi)容不是你想要的,需要傳入headers

陌顏 回答

按照nginx官網(wǎng)的說明,server_name中的多個(gè)域名應(yīng)該以空格分隔,而不應(yīng)該以逗號(hào)分隔。

安淺陌 回答

command+shift+P進(jìn)Command Palette,輸入python: Select Interpreter,選擇你需要的環(huán)境。