主頁 > .NET開發 > 如何在python中將多個字典物件組合成一個串列?

如何在python中將多個字典物件組合成一個串列?

2022-05-10 10:37:53 .NET開發

我已經嘗試了幾個小時來完成這項作業。我正在嘗試從檔案中讀取并將所有資料組織到字典中,然后將所有字典組合到串列中。但是,我已經將所有資料都放入字典中,但是每當我嘗試將它們附加到 =list 每次迭代時,它要么完全中斷,要么只添加檔案的最后一行??`def

readParkFile(fileName="national_parks.csv"):
    f = open(fileName, "r")
    parkList = []
    parkDict = {}
    header = f.readline().split(",")
    keys = list(header)

    for line in f:
        tmp = list(line.split(","))
        quote = tmp[7:]
        fullQuote = ','.join(quote)
        del tmp[7:]
        tmp.append(fullQuote)
        for value in tmp:
            parkDict[keys[tmp.index(value)]] = value
        parkList.append(parkDict)
        print(parkDict)

readParkFile()`

Code,Name,State,Acres,Latitude,Longitude,Date,Description ACAD,Acadia National Park,ME,47390,44.35,-68.21,1919-02-26,"覆寫沙漠山島大部分地區及其他沿海島嶼,阿卡迪亞特色美國大西洋沿岸最高的山峰、花崗巖山峰、海洋海岸線、林地和湖泊。有淡水、河口、森林和潮間帶棲息地。” ARCH,Arches National Park,UT,76519,38.68,-109.57,1971-11-12,”該站點擁有 2,000 多個天然砂巖拱門,公園內最受歡迎的拱門是精致拱門、景觀拱門和雙拱門Arch. 數百萬年的侵蝕在沙漠氣候中創造了這些結構,在干旱的土地上有維持生命的生物土壤結皮和坑洼,作為天然的集水盆地。其他地質構造包括石尖峰、鰭狀物和平衡巖。” BADL,Badlands National Park,SD,242756,43.75,-102.5,1978-11-10,“The Badlands 是小山丘、尖峰、尖頂和混合-草草原。白河荒地包含已知的始新世晚期和漸新世哺乳動物化石的最大組合。野生動物包括野牛、大角羊、黑腳雪貂和草原土撥鼠。” BIBE,Big Bend National Park,TX,801163,29.25,-103.25,1944-06-12,”以格蘭德河的突出彎道命名沿著美墨邊境,這個公園包括奇瓦瓦沙漠的一大片偏遠地區。它的主要吸引力是在干旱的奇索斯山脈和沿河峽谷的野外休閑活動。各種各樣的白堊紀和第三紀化石以及美洲原住民的文物也存在于其境內。”BISC,比斯坎國家公園,FL,172924,25.65,-80.08,1980-06-28,“比斯坎的中部灣,這個位于佛羅里達礁島群北端的大部分水下公園擁有四個相互關聯的海洋生態系統:紅樹林、海灣、礁島群和珊瑚礁。受威脅的動物包括西印度海牛、美洲鱷魚、各種海龜和游隼。” BLCA,甘尼森國家公園黑峽谷,CO,32950,38.57,-107.72,1999-10-21,“公園保護甘尼森河的四分之一,從前寒武紀時期的黑暗巖石上切下陡峭的峽谷壁。峽谷擁有北美最陡峭的懸崖和最古老的巖石,是河流漂流和攀巖的熱門場所。深而窄的峽谷由片麻巖和片巖組成,在陰影中呈現黑色。”BRCA,布萊斯峽谷國家公園,UT,35835,37.57,-112.18,1928-02-25,”布萊斯峽谷是一個地質圓形劇場Paunsagunt 高原有數百個由侵蝕形成的高大、多彩多姿的砂巖不祥之物。該地區最初由美洲原住民定居,后來由摩門教先驅者定居。" CANY,Canyonlands National Park,UT,337598,38.2,-109.93,1964-09-12,"這片景觀被侵蝕成一個由峽谷、小山丘和科羅拉多河、格林河及其支流的共同努力,將公園分為三個區域。該公園還包含巖石尖峰和拱門,以及古代普韋布洛人的文物。”CARE, Capitol Reef National Park,UT,241904,38.2,-111.17,1971-12-18,“公園的水袋褶皺是一個 100 英里(160 公里)的單斜,展示了地球上不同的地質層。其他自然特征包括巨石、懸崖,以及形狀像美國國會大廈的砂巖圓頂。” CAVE,Carlsbad Caverns National Park,NM,46766,32.17,-104.44,1930-05-14,"Carlsbad Caverns 有 117 個洞穴,其中最長的超過 120 英里(190 公里)長。大房間將近 4,000 英尺(1,200 m)長,洞穴是超過 400,000 只墨西哥無尾蝙蝠和 16 種其他物種的家園。地上是奇瓦瓦沙漠和響尾蛇溫泉。” CHIS,海峽群島國家公園,CA,249561,34.01,-119.42,1980-03-05,"海峽群島八個島嶼中的五個受到保護,公園面積的一半在水下。這些島嶼擁有獨特的地中海生態系統,最初由丘馬什人定居。它們是超過 2,000 種陸地動植物的家園,其中 145 種是它們特有的,包括島狐。渡輪服務提供從大陸到島嶼的交通服務。" CONG,Congaree National Park,SC,26546,33.78,-80.78,2003-11-10,"在 Congaree 河上,這個公園是古老洪泛區最大的部分北美留下的森林。有些樹是美國東部最高的。一條名為 Boardwalk Loop 的高架人行道引導游客穿過沼澤。" CRLA,Crater Lake National Park,OR,183224,42.94,-122.1,1902-05-22,"Crater Lake 位于一座名為 Mount Mazama 的古老火山的火山口中7700年前倒塌。該湖是美國最深的湖,以其鮮艷的藍色和清澈的水而聞名。巫師島和幻影船是火山口內較新的火山構造。由于湖沒有入口或出口,只能通過降水來補充。" CUVA,Cuyahoga Valley National Park,OH,32950,41.24,-81.55,2000-10-11,"Cuyahoga River 沿岸的這個公園有瀑布、丘陵、小徑和早期鄉村生活的展覽。俄亥俄和伊利運河拖船小徑沿著俄亥俄和伊利運河,騾子拖著運河船。該公園擁有眾多歷史悠久的住宅、橋梁和建筑,還提供風景優美的火車之旅。” " CUVA,Cuyahoga Valley National Park,OH,32950,41.24,-81.55,2000-10-11,"這個位于 Cuyahoga 河沿岸的公園有瀑布、丘陵、小徑和早期鄉村生活的展覽。俄亥俄和伊利運河拖船小徑沿著俄亥俄和伊利運河,騾子拖著運河船。該公園擁有眾多歷史悠久的住宅、橋梁和建筑,還提供風景優美的火車之旅。” " CUVA,Cuyahoga Valley National Park,OH,32950,41.24,-81.55,2000-10-11,"這個位于 Cuyahoga 河沿岸的公園有瀑布、丘陵、小徑和早期鄉村生活的展覽。俄亥俄和伊利運河拖船小徑沿著俄亥俄和伊利運河,騾子拖著運河船。該公園擁有眾多歷史悠久的住宅、橋梁和建筑,還提供風景優美的火車之旅。”

預期輸出:

[{“code”:, “name”: …},{“code”:, “name”: …}, {“code”:, “name”: …}]

uj5u.com熱心網友回復:

我復制了您的輸入,在 CSV 中的每一行之前添加了換行符(請參見此處),并將字典的初始化移到回圈中。運行此代碼:

from pprint import pprint

def readParkFile(fileName="temp.csv"):
    f = open(fileName, "r")
    parkList = []
    header = f.readline().split(",")
    keys = list(header)

    for line in f:
        parkDict = {}  # This is the issue! Moving the initialization of this dictionary into the loop.
        tmp = list(line.split(","))
        quote = tmp[7:]
        fullQuote = ','.join(quote)
        del tmp[7:]
        tmp.append(fullQuote)
        for value in tmp:
            parkDict[keys[tmp.index(value)]] = value
        # pprint(parkDict)
        parkList.append(parkDict)
    # pprint(parkList)

if __name__ == '__main__':
    readParkFile()

你會得到這個輸出:

[{'Acres': '47390',
  'Code': 'ACAD',
  'Date': '1919-02-26',
  'Description \n': '"Covering most of Mount Desert Island and other coastal '
                    'islands, Acadia features the tallest mountain on the '
                    'Atlantic coast of the United States, granite peaks, ocean '
                    'shoreline, woodlands, and lakes. There are freshwater, '
                    'estuary, forest, and intertidal habitats." \n',
  'Latitude': '44.35',
  'Longitude': '-68.21',
  'Name': 'Acadia National Park',
  'State': 'ME'},
 {'Acres': '76519',
  'Code': 'ARCH',
  'Date': '1971-11-12',
  'Description \n': '"This site features more than 2\\,000 natural sandstone '
                    'arches, with some of the most popular arches in the park '
                    'being Delicate Arch, Landscape Arch and Double Arch. '
                    'Millions of years of erosion have created these '
                    'structures in a desert climate where the arid ground has '
                    'life-sustaining biological soil crusts and potholes that '
                    'serve as natural water-collecting basins. Other geologic '
                    'formations include stone pinnacles, fins, and balancing '
                    'rocks." \n',
  'Latitude': '38.68',
  'Longitude': '-109.57',
  'Name': 'Arches National Park',
  'State': 'UT'},
 {'Acres': '242756',
  'Code': 'BADL',
  'Date': '1978-11-10',
  'Description \n': '"The Badlands are a collection of buttes, pinnacles, '
                    'spires, and mixed-grass prairies. The White River '
                    'Badlands contain the largest assemblage of known late '
                    'Eocene and Oligocene mammal fossils. The wildlife '
                    'includes bison, bighorn sheep, black-footed ferrets, and '
                    'prairie dogs."\n',
  'Latitude': '43.75',
  'Longitude': '-102.5',
  'Name': 'Badlands National Park',
  'State': 'SD'},
 {'Acres': '801163',
  'Code': 'BIBE',
  'Date': '1944-06-12',
  'Description \n': '"Named for the prominent bend in the Rio Grande along the '
                    'U.S.-Mexico border, this park encompasses a large and '
                    'remote part of the Chihuahuan Desert. Its main attraction '
                    'is backcountry recreation in the arid Chisos Mountains '
                    'and in canyons along the river. A wide variety of '
                    'Cretaceous and Tertiary fossils as well as cultural '
                    'artifacts of Native Americans also exist within its '
                    'borders." \n',
  'Latitude': '29.25',
  'Longitude': '-103.25',
  'Name': 'Big Bend National Park',
  'State': 'TX'},
 {'Acres': '172924',
  'Code': 'BISC',
  'Date': '1980-06-28',
  'Description \n': '"The central part of Biscayne Bay, this mostly underwater '
                    'park at the north end of the Florida Keys has four '
                    'interrelated marine ecosystems: mangrove forest, the Bay, '
                    'the Keys, and coral reefs. Threatened animals include the '
                    'West Indian manatee, American crocodile, various sea '
                    'turtles, and peregrine falcon." \n',
  'Latitude': '25.65',
  'Longitude': '-80.08',
  'Name': 'Biscayne National Park',
  'State': 'FL'},
 {'Acres': '32950',
  'Code': 'BLCA',
  'Date': '1999-10-21',
  'Description \n': '"The park protects a quarter of the Gunnison River, which '
                    'slices sheer canyon walls from dark Precambrian-era rock. '
                    'The canyon features some of the steepest cliffs and '
                    'oldest rock in North America, and is a popular site for '
                    'river rafting and rock climbing. The deep, narrow canyon '
                    'is composed of gneiss and schist, which appears black '
                    'when in shadow." \n',
  'Latitude': '38.57',
  'Longitude': '-107.72',
  'Name': 'Black Canyon of the Gunnison National Park',
  'State': 'CO'},
 {'Acres': '35835',
  'Code': 'BRCA',
  'Date': '1928-02-25',
  'Description \n': '"Bryce Canyon is a geological amphitheater on the '
                    'Paunsaugunt Plateau with hundreds of tall, multicolored '
                    'sandstone hoodoos formed by erosion. The region was '
                    'originally settled by Native Americans and later by '
                    'Mormon pioneers." \n',
  'Latitude': '37.57',
  'Longitude': '-112.18',
  'Name': 'Bryce Canyon National Park',
  'State': 'UT'},
 {'Acres': '337598',
  'Code': 'CANY',
  'Date': '1964-09-12',
  'Description \n': '"This landscape was eroded into a maze of canyons, '
                    'buttes, and mesas by the combined efforts of the Colorado '
                    'River, Green River, and their tributaries, which divide '
                    'the park into three districts. The park also contains '
                    'rock pinnacles and arches, as well as artifacts from '
                    'Ancient Pueblo peoples." \n',
  'Latitude': '38.2',
  'Longitude': '-109.93',
  'Name': 'Canyonlands National Park',
  'State': 'UT'},
 {'Acres': '241904',
  'Code': 'CARE',
  'Date': '1971-12-18',
  'Description \n': '"The park\'s Waterpocket Fold is a 100-mile (160 km) '
                    "monocline that exhibits the earth's diverse geologic "
                    'layers. Other natural features include monoliths, cliffs, '
                    'and sandstone domes shaped like the United States '
                    'Capitol." \n',
  'Latitude': '38.2',
  'Longitude': '-111.17',
  'Name': 'Capitol Reef National Park',
  'State': 'UT'},
 {'Acres': '46766',
  'Code': 'CAVE',
  'Date': '1930-05-14',
  'Description \n': '"Carlsbad Caverns has 117 caves, the longest of which is '
                    'over 120 miles (190 km) long. The Big Room is almost '
                    '4,000 feet (1,200 m) long, and the caves are home to over '
                    '400,000 Mexican free-tailed bats and sixteen other '
                    'species. Above ground are the Chihuahuan Desert and '
                    'Rattlesnake Springs." \n',
  'Latitude': '32.17',
  'Longitude': '-104.44',
  'Name': 'Carlsbad Caverns National Park',
  'State': 'NM'},
 {'Acres': '249561',
  'Code': 'CHIS',
  'Date': '1980-03-05',
  'Description \n': '"Five of the eight Channel Islands are protected, with '
                    "half of the park's area underwater. The islands have a "
                    'unique Mediterranean ecosystem originally settled by the '
                    'Chumash people. They are home to over 2,000 species of '
                    'land plants and animals, 145 endemic to them, including '
                    'the island fox. Ferry services offer transportation to '
                    'the islands from the mainland." \n',
  'Latitude': '34.01',
  'Longitude': '-119.42',
  'Name': 'Channel Islands National Park',
  'State': 'CA'},
 {'Acres': '26546',
  'Code': 'CONG',
  'Date': '2003-11-10',
  'Description \n': '"On the Congaree River, this park is the largest portion '
                    'of old-growth floodplain forest left in North America. '
                    'Some of the trees are the tallest in the eastern United '
                    'States. An elevated walkway called the Boardwalk Loop '
                    'guides visitors through the swamp." \n',
  'Latitude': '33.78',
  'Longitude': '-80.78',
  'Name': 'Congaree National Park',
  'State': 'SC'},
 {'Acres': '183224',
  'Code': 'CRLA',
  'Date': '1902-05-22',
  'Description \n': '"Crater Lake lies in the caldera of an ancient volcano '
                    'called Mount Mazama that collapsed 7,700 years ago. The '
                    'lake is the deepest in the United States and is noted for '
                    'its vivid blue color and water clarity. Wizard Island and '
                    'the Phantom Ship are more recent volcanic formations '
                    'within the caldera. As the lake has no inlets or outlets, '
                    'it is replenished only by precipitation." \n',
  'Latitude': '42.94',
  'Longitude': '-122.1',
  'Name': 'Crater Lake National Park',
  'State': 'OR'},
 {'Acres': '32950',
  'Code': 'CUVA',
  'Date': '2000-10-11',
  'Description \n': '"This park along the Cuyahoga River has waterfalls, '
                    'hills, trails, and exhibits on early rural living. The '
                    'Ohio and Erie Canal Towpath Trail follows the Ohio and '
                    'Erie Canal, where mules towed canal boats. The park has '
                    'numerous historic homes, bridges, and structures, and '
                    'also offers a scenic train ride."\n',
  'Latitude': '41.24',
  'Longitude': '-81.55',
  'Name': 'Cuyahoga Valley National Park',
  'State': 'OH'}]

uj5u.com熱心網友回復:

您提供的輸入并沒有真正的幫助。提供輸入時,盡量讓復制粘貼變得容易。我們無法將其復制并粘貼到 .csv 檔案中。

無論如何,我為此制作了一個小的 .csv,我認為這段代碼提供了你想要的:

finalList = []
with open('smth.csv','r') as file:          
    keys = file.readline().split(',') 
    line = file.readline().split(',')
    while line: # Exits when readline returns an empty line 
        finalList.append({keys[0]: line[0],
                            keys[1]: line[1],
                            keys[2]: line[2]  
                            })
        line = file.readline()

您還可以通過使用file.readlines()which 一次回傳來縮短此時間。

uj5u.com熱心網友回復:

注意:您可能希望為此使用熊貓。請參閱此答案的后半部分以獲取示例。)

直接回答您的問題: 如果您想要實際鍵入的值(int 表示英畝,float 表示緯度/經度),這是一種使用正則運算式的方法:

import re
def readParkFile(fileName="national_parks.csv"):
    parkList = []
    f = open(fileName, "r")
    keys = f.readline().strip("\n").split(",")
    for line in f:
        v = re.search('(.*?),(.*?),(.*?),(.*?),(.*?),(.*?),(.*?),(.*)', line).groups()
        Code, Name, State, Acres, Latitude, Longitude, Date, Description = v[0], v[1], v[2], int(v[3]), float(v[4]), float(v[5]), v[6], v[7][1:-1]
        parkDict = dict(zip(keys, [Code, Name, State, Acres, Latitude, Longitude, Date, Description]))
        parkList.append(parkDict)
    return parkList

parkList = readParkFile()

在回圈內部,re.search()在除最后一個 ( ) 之外的所有逗號分隔組中使用非貪婪限定符Description,然后將數字欄位轉換為數字并從Description. 然后將這些型別的值與keysusing組合zip()并轉換為 a dict,然后將其附加到結果中,parkList. 遍歷 csv 檔案中的所有行后,函式回傳parkList.

結果字典串列的第一個字典元素如下所示:

{'Code': 'ACAD', 'Name': 'Acadia National Park', 'State': 'ME', 'Acres': 47390, 'Latitude': 44.35, 'Longitude': -68.21, 'Date': '1919-02-26', 'Description': 'Covering most of Mount Desert Island and other coastal islands, Acadia features the tallest mountain on the Atlantic coast of the United States, granite peaks, ocean shoreline, woodlands, and lakes. There are freshwater, estuary, forest, and intertidal habitats.'}

使用 pandas 的另一種方法: 在 pandas 中,您可以這樣做:

import pandas as pd
df = pd.read_csv("national_parks.csv")
print(df)
print(df.dtypes)
parkList = df.to_dict('records')
print(parkList[0])

它將給出以下輸出:

    Code                                        Name State   Acres  Latitude  Longitude        Date                                        Description
0   ACAD                        Acadia National Park    ME   47390     44.35     -68.21  1919-02-26  Covering most of Mount Desert Island and other...
1   ARCH                        Arches National Park    UT   76519     38.68    -109.57  1971-11-12  This site features more than 2,000 natural san...
2   BADL                      Badlands National Park    SD  242756     43.75    -102.50  1978-11-10  The Badlands are a collection of buttes, pinna...
3   BIBE                      Big Bend National Park    TX  801163     29.25    -103.25  1944-06-12  Named for the prominent bend in the Rio Grande...
4   BISC                      Biscayne National Park    FL  172924     25.65     -80.08  1980-06-28  The central part of Biscayne Bay, this mostly ...
5   BLCA  Black Canyon of the Gunnison National Park    CO   32950     38.57    -107.72  1999-10-21  The park protects a quarter of the Gunnison Ri...
6   BRCA                  Bryce Canyon National Park    UT   35835     37.57    -112.18  1928-02-25  Bryce Canyon is a geological amphitheater on t...
7   CANY                   Canyonlands National Park    UT  337598     38.20    -109.93  1964-09-12  This landscape was eroded into a maze of canyo...
8   CARE                  Capitol Reef National Park    UT  241904     38.20    -111.17  1971-12-18  The park's Waterpocket Fold is a 100-mile (160...
9   CAVE              Carlsbad Caverns National Park    NM   46766     32.17    -104.44  1930-05-14  Carlsbad Caverns has 117 caves, the longest of...
10  CHIS               Channel Islands National Park    CA  249561     34.01    -119.42  1980-03-05  Five of the eight Channel Islands are protecte...
11  CONG                      Congaree National Park    SC   26546     33.78     -80.78  2003-11-10  On the Congaree River, this park is the larges...
12  CRLA                   Crater Lake National Park    OR  183224     42.94    -122.10  1902-05-22  Crater Lake lies in the caldera of an ancient ...
13  CUVA               Cuyahoga Valley National Park    OH   32950     41.24     -81.55  2000-10-11  This park along the Cuyahoga River has waterfa...
Code            object
Name            object
State           object
Acres            int64
Latitude       float64
Longitude      float64
Date            object
Description     object
dtype: object
{'Code': 'ACAD', 'Name': 'Acadia National Park', 'State': 'ME', 'Acres': 47390, 'Latitude': 44.35, 'Longitude': -68.21, 'Date': '1919-02-26', 'Description': 'Covering most of Mount Desert Island and other coastal islands, Acadia features the tallest mountain on the Atlantic coast of the United States, granite peaks, ocean shoreline, woodlands, and lakes. There are freshwater, estuary, forest, and intertidal habitats.'}

正如你所看到的,通過一次呼叫read_csv(),pandas 決議 csv 檔案,計算出每一列的資料型別,并將所有這些組合成一個 DataFrame 物件。to_dict()然后,您可以通過使用引數呼叫 DataFrame 物件的方法來獲取您正在嘗試的字典串列'records'

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/472000.html

標籤:Python 列表 字典

上一篇:組合兩個行串列

下一篇:自舉模態中的未定義變數-Laravel

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • WebAPI簡介

    Web體系結構: 有三個核心:資源(resource),URL(統一資源識別符號)和表示 他們的關系是這樣的:一個資源由一個URL進行標識,HTTP客戶端使用URL定位資源,表示是從資源回傳資料,媒體型別是資源回傳的資料格式。 接下來我們說下HTTP. HTTP協議的系統是一種無狀態的方式,使用請求/ ......

    uj5u.com 2020-09-09 22:07:47 more
  • asp.net core 3.1 入口:Program.cs中的Main函式

    本文分析Program.cs 中Main()函式中代碼的運行順序分析asp.net core程式的啟動,重點不是剖析原始碼,而是理清程式開始時執行的順序。到呼叫了哪些實體,哪些法方。asp.net core 3.1 的程式入口在專案Program.cs檔案里,如下。ususing System; us ......

    uj5u.com 2020-09-09 22:07:49 more
  • asp.net網站作為websocket服務端的應用該如何寫

    最近被websocket的一個問題困擾了很久,有一個需求是在web網站中搭建websocket服務。客戶端通過網頁與服務器建立連接,然后服務器根據ip給客戶端網頁發送資訊。 其實,這個需求并不難,只是剛開始對websocket的內容不太了解。上網搜索了一下,有通過asp.net core 實作的、有 ......

    uj5u.com 2020-09-09 22:08:02 more
  • ASP.NET 開源匯入匯出庫Magicodes.IE Docker中使用

    Magicodes.IE在Docker中使用 更新歷史 2019.02.13 【Nuget】版本更新到2.0.2 【匯入】修復單列匯入的Bug,單元測驗“OneColumnImporter_Test”。問題見(https://github.com/dotnetcore/Magicodes.IE/is ......

    uj5u.com 2020-09-09 22:08:05 more
  • 在webform中使用ajax

    如果你用過Asp.net webform, 說明你也算是.NET 開發的老兵了。WEBform應該是2011 2013左右,當時還用visual studio 2005、 visual studio 2008。后來基本都用的是MVC。 如果是新開發的專案,估計沒人會用webform技術。但是有些舊版 ......

    uj5u.com 2020-09-09 22:08:50 more
  • iis添加asp.net網站,訪問提示:由于擴展配置問題而無法提供您請求的

    今天在iis服務器配置asp.net網站,遇到一個問題,記錄一下: 問題:由于擴展配置問題而無法提供您請求的頁面。如果該頁面是腳本,請添加處理程式。如果應下載檔案,請添加 MIME 映射。 WindowServer2012服務器,添加角色安裝完.netframework和iis之后,運行aspx頁面 ......

    uj5u.com 2020-09-09 22:10:00 more
  • WebAPI-處理架構

    帶著問題去思考,大家好! 問題1:HTTP請求和回傳相應的HTTP回應資訊之間發生了什么? 1:首先是最底層,托管層,位于WebAPI和底層HTTP堆疊之間 2:其次是 訊息處理程式管道層,這里比如日志和快取。OWIN的參考是將訊息處理程式管道的一些功能下移到堆疊下端的OWIN中間件了。 3:控制器處理 ......

    uj5u.com 2020-09-09 22:11:13 more
  • 微信門戶開發框架-使用指導說明書

    微信門戶應用管理系統,采用基于 MVC + Bootstrap + Ajax + Enterprise Library的技術路線,界面層采用Boostrap + Metronic組合的前端框架,資料訪問層支持Oracle、SQLServer、MySQL、PostgreSQL等資料庫。框架以MVC5,... ......

    uj5u.com 2020-09-09 22:15:18 more
  • WebAPI-HTTP編程模型

    帶著問題去思考,大家好!它是什么?它包含什么?它能干什么? 訊息 HTTP編程模型的核心就是訊息抽象,表示為:HttPRequestMessage,HttpResponseMessage.用于客戶端和服務端之間交換請求和回應訊息。 HttpMethod類包含了一組靜態屬性: private stat ......

    uj5u.com 2020-09-09 22:15:23 more
  • 部署WebApi隨筆

    一、跨域 NuGet參考Microsoft.AspNet.WebApi.Cors WebApiConfig.cs中配置: // Web API 配置和服務 config.EnableCors(new EnableCorsAttribute("*", "*", "*")); 二、清除默認回傳XML格式 ......

    uj5u.com 2020-09-09 22:15:48 more
最新发布
  • C#多執行緒學習(二) 如何操縱一個執行緒

    <a href="https://www.cnblogs.com/x-zhi/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2943582/20220801082530.png" alt="" /></...

    uj5u.com 2023-04-19 09:17:20 more
  • C#多執行緒學習(二) 如何操縱一個執行緒

    C#多執行緒學習(二) 如何操縱一個執行緒 執行緒學習第一篇:C#多執行緒學習(一) 多執行緒的相關概念 下面我們就動手來創建一個執行緒,使用Thread類創建執行緒時,只需提供執行緒入口即可。(執行緒入口使程式知道該讓這個執行緒干什么事) 在C#中,執行緒入口是通過ThreadStart代理(delegate)來提供的 ......

    uj5u.com 2023-04-19 09:16:49 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    <a href="https://www.cnblogs.com/huangxincheng/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/214741/20200614104537.png" alt="" /&g...

    uj5u.com 2023-04-18 08:39:04 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    一:背景 1. 講故事 前段時間協助訓練營里的一位朋友分析了一個程式卡死的問題,回過頭來看這個案例比較經典,這篇稍微整理一下供后來者少踩坑吧。 二:WinDbg 分析 1. 為什么會卡死 因為是表單程式,理所當然就是看主執行緒此時正在做什么? 可以用 ~0s ; k 看一下便知。 0:000> k # ......

    uj5u.com 2023-04-18 08:33:10 more
  • SignalR, No Connection with that ID,IIS

    <a href="https://www.cnblogs.com/smartstar/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/u36196.jpg" alt="" /></a>...

    uj5u.com 2023-03-30 17:21:52 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:15:33 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:13:31 more
  • C#遍歷指定檔案夾中所有檔案的3種方法

    <a href="https://www.cnblogs.com/xbhp/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/957602/20230310105611.png" alt="" /></a&...

    uj5u.com 2023-03-27 14:46:55 more
  • C#/VB.NET:如何將PDF轉為PDF/A

    <a href="https://www.cnblogs.com/Carina-baby/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2859233/20220427162558.png" alt="" />...

    uj5u.com 2023-03-27 14:46:35 more
  • 武裝你的WEBAPI-OData聚合查詢

    <a href="https://www.cnblogs.com/podolski/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/616093/20140323000327.png" alt="" /><...

    uj5u.com 2023-03-27 14:46:16 more