python練習題 -股票查詢


源文件:

股票代碼,股票名稱,當前價,漲跌額,漲跌幅,年初至今,成交量,成交額,換手率,市盈率(TTM),股息率,市值
SH601778,N晶科,6.29,+1.92,+43.94%,+43.94%,259.66萬,1625.52萬,0.44%,22.32,-,173.95億
SH688566,吉貝爾,52.66,+6.96,+15.23%,+122.29%,1626.58萬,8.09億,42.29%,89.34,-,98.44億
SH688268,華特氣體,88.80,+11.72,+15.20%,+102.51%,622.60萬,5.13億,22.87%,150.47,-,106.56億
SH600734,實達集團,2.60,+0.24,+10.17%,-61.71%,1340.27萬,3391.14萬,2.58%,虧損,0.00%,16.18億
SH900957,凌雲B股,0.36,+0.033,+10.09%,-35.25%,119.15萬,42.10萬,0.65%,44.65,0.00%,1.26億
SZ000584,哈工智能,6.01,+0.55,+10.07%,-4.15%,2610.86萬,1.53億,4.36%,199.33,0.26%,36.86億
SH600599,熊貓金控,6.78,+0.62,+10.06%,-35.55%,599.64萬,3900.23萬,3.61%,虧損,0.00%,11.25億
SH600520,文一科技,8.21,+0.75,+10.05%,-24.05%,552.34萬,4464.69萬,3.49%,虧損,0.00%,13.01億
SH603682,錦和商業,11.73,+1.07,+10.04%,+48.29%,2746.63萬,3.15億,29.06%,29.62,-,55.42億
SZ300831,派瑞股份,12.27,+1.12,+10.04%,+208.29%,25.38萬,311.41萬,0.32%,60.59,-,39.26億
SH900939,匯麗B,0.504,+0.046,+10.04%,-23.52%,123.86萬,61.86萬,1.41%,52.80,0.00%,9147.60萬
SH600880,博瑞傳播,4.39,+0.40,+10.03%,+10.03%,1117.75萬,4816.57萬,1.02%,95.87,0.50%,48.00億
SZ000609,中迪投資,7.68,+0.70,+10.03%,+39.64%,2663.08萬,2.00億,9.12%,58.84,0.00%,22.98億
SZ300328,宜安科技,15.80,+1.44,+10.03%,+7.19%,432.45萬,6832.68萬,0.95%,64.80,0.51%,72.72億
SZ002988,豪美新材,17.33,+1.58,+10.03%,+58.41%,3.50萬,60.68萬,0.06%,24.42,-,40.34億
SZ000615,京漢股份,4.61,+0.42,+10.02%,+4.06%,518.09萬,2388.41萬,0.69%,虧損,0.00%,36.06億
SZ300443,金雷股份,18.33,+1.67,+10.02%,+32.74%,987.25萬,1.75億,6.19%,18.78,1.08%,43.64億
SH600506,香梨股份,11.42,+1.04,+10.02%,+11.96%,1039.48萬,1.18億,7.04%,虧損,0.00%,16.87億
SZ300505,川金諾,15.61,+1.42,+10.01%,-11.26%,493.54萬,7555.40萬,6.03%,26.70,0.85%,20.40億
SZ300830,金現代,14.95,+1.36,+10.01%,+239.77%,63.66萬,951.76萬,0.74%,70.76,0.00%,64.30億
SH603630,拉芳家化,17.26,+1.57,+10.01%,+27.85%,949.49萬,1.60億,4.19%,209.44,0.83%,39.13億
SZ002655,共達電聲,11.43,+1.04,+10.01%,-14.64%,1683.51萬,1.88億,4.68%,166.69,0.00%,41.15億
SZ300460,惠倫晶體,16.59,+1.51,+10.01%,+0.97%,430.28萬,6974.52萬,2.56%,虧損,0.00%,27.92億
SH603929,亞翔集成,20.33,+1.85,+10.01%,+33.40%,1373.66萬,2.76億,6.44%,84.29,1.25%,43.38億
SH603392,萬泰生物,35.97,+3.27,+10.00%,+311.09%,6.92萬,248.91萬,0.16%,65.24,-,155.97億
SZ000788,北大醫葯,6.82,+0.62,+10.00%,+2.40%,832.44萬,5583.87萬,1.40%,89.69,0.32%,40.65億
SH601609,金田銅業,10.89,+0.99,+10.00%,+66.26%,4027.64萬,4.28億,16.64%,32.38,0.32%,158.66億
SZ000403,雙林生物,52.48,+4.77,+10.00%,+62.48%,171.75萬,9013.54萬,0.63%,88.80,0.23%,143.05億
SZ300832,新產業,72.80,+6.62,+10.00%,+131.92%,10.73萬,780.85萬,0.26%,40.20,0.62%,299.64億
SZ002985,北摩高科,92.58,+8.42,+10.00%,+310.92%,2422.97萬,21.55億,64.54%,60.48,1.08%,139.02億
SH603348,文燦股份,18.06,+1.64,+9.99%,-25.15%,357.86萬,6328.87萬,4.39%,89.39,0.89%,41.83億
SH603900,萊紳通靈,8.92,+0.81,+9.99%,-5.61%,1364.10萬,1.15億,4.01%,43.78,5.06%,30.37億
SH603042,華脈科技,17.85,+1.62,+9.98%,+17.05%,491.44萬,8705.99萬,4.86%,128.50,0.31%,24.28億
SZ300260,新萊應材,19.83,+1.80,+9.98%,+68.48%,1800.45萬,3.48億,14.16%,65.15,0.73%,40.04億
SZ000557,西部創業,3.42,+0.31,+9.97%,-0.87%,2751.17萬,9408.89萬,1.89%,79.39,0.00%,49.88億
SZ300716,國立科技,9.94,+0.90,+9.96%,-4.24%,142.25萬,1413.92萬,1.50%,虧損,0.29%,15.91億
SZ002449,國星光電,11.92,+1.08,+9.96%,-6.80%,5185.52萬,6.03億,8.53%,21.51,2.73%,73.72億

data = {}

with open('stock_info', 'r', encoding='gbk') as f:
    for ID_num, line in enumerate(f):
        data[ID_num] = line.strip().split(',')
index_col = data[0]
del data[0]
# print(data)
# print(index_col)
while True:

    count = 0
    choice = input('股票查詢接口〉〉:').strip()
    if choice == '':
        print('輸入的信息有誤,請重新輸入')
        continue
    elif choice.isalpha():
        print(index_col)
        for i in range(1, len(data) + 1):
            if choice in data[i][1]:
                print(data[i])
                count += 1
        print('找到%s條' % count)
    else:
        choice = choice.split()
        target = index_col.index(choice[0])
        print(index_col)
        for i in range(1, len(data) + 1):
            if choice[2] != '虧損':
                if choice[2].endswith('%') or choice[2].endswith('') or choice[2].endswith(''):
                    while True:
                        if data[i][target][-1] == choice[2][-1]:
                            if eval(data[i][target][:-1] + choice[1] + choice[2][:-1]):
                                print(data[i])
                                count += 1
                                break
                            else:
                                break
                        elif choice[2][-1] == '':
                            choice[2] = str(eval(choice[2][:-1]) * 10000) + ''
                        elif choice[2][-1] == '':
                            choice[2] = str(eval(choice[2][:-1]) / 10000) + ''
                        elif data[i][target] == '-':
                            data[i][target] = '0%'
                else:
                    if data[i][target] != '虧損':
                        if eval(data[i][target] + choice[1] + choice[2]):
                            print(data[i])
                            count += 1
            else:
                if data[i][target] == '虧損':
                    print(data[i])
                    count += 1

        print('找到%s條' % count)
股票查詢接口〉〉:市盈率(TTM) = 虧損
['股票代碼', '股票名稱', '當前價', '漲跌額', '漲跌幅', '年初至今', '成交量', '成交額', '換手率', '市盈率(TTM)', '股息率', '市值']
['SH600734', '實達集團', '2.60', '+0.24', '+10.17%', '-61.71%', '1340.27萬', '3391.14萬', '2.58%', '虧損', '0.00%', '16.18億']
['SH600599', '熊貓金控', '6.78', '+0.62', '+10.06%', '-35.55%', '599.64萬', '3900.23萬', '3.61%', '虧損', '0.00%', '11.25億']
['SH600520', '文一科技', '8.21', '+0.75', '+10.05%', '-24.05%', '552.34萬', '4464.69萬', '3.49%', '虧損', '0.00%', '13.01億']
['SZ000615', '京漢股份', '4.61', '+0.42', '+10.02%', '+4.06%', '518.09萬', '2388.41萬', '0.69%', '虧損', '0.00%', '36.06億']
['SH600506', '香梨股份', '11.42', '+1.04', '+10.02%', '+11.96%', '1039.48萬', '1.18億', '7.04%', '虧損', '0.00%', '16.87億']
['SZ300460', '惠倫晶體', '16.59', '+1.51', '+10.01%', '+0.97%', '430.28萬', '6974.52萬', '2.56%', '虧損', '0.00%', '27.92億']
['SZ300716', '國立科技', '9.94', '+0.90', '+9.96%', '-4.24%', '142.25萬', '1413.92萬', '1.50%', '虧損', '0.29%', '15.91億']
找到7條
View Code
股票查詢接口〉〉:市值 < 10億
['股票代碼', '股票名稱', '當前價', '漲跌額', '漲跌幅', '年初至今', '成交量', '成交額', '換手率', '市盈率(TTM)', '股息率', '市值']
['SH900957', '凌雲B股', '0.36', '+0.033', '+10.09%', '-35.25%', '119.15萬', '42.10萬', '0.65%', '44.65', '0.00%', '1.26億']
['SH900939', '匯麗B', '0.504', '+0.046', '+10.04%', '-23.52%', '123.86萬', '61.86萬', '1.41%', '52.80', '0.00%', '9147.60萬']
找到2條
View Code

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM