A method based on UV absorption spectroscopy with polyethylenimine(PEI) solution was proposed for the rapid and accurate detection of H2S gas in oil and gas fields.The amino groups in PEI reacted with H2S gas while it was bubbled into PEI solution,which could be utilized in the detection of H2S concentration.The UV absorption spectra of PEI solution were measured before and after bubbling H2S gas,and the absorbance near absorption line 230 nm and 365 nm of UV absorption spectra was analyzed.H2S gas samples with standard concentration were prepared for concentration calibration tests,and the relationship between gas concentration and UV absorbance was studied.The experimental results showed that a good linear relationship between H2S gas concentration and UV absorbance of PEI solution was obtained,with a correlation coefficient(r2) of 0.970 6.Meanwhile,the limit of detection for H2S gas reached to 15.39 mg/m3.UV absorbance analysis on PEI solution could be used for the rapid determination of H2S gas in oil and gas fields.