Python ကျူတိုရီရယ်

Python ပင်မစာမျက်နှာ Python နိဒါန်း Python ကို စတင်လိုက်ပါ။ Python Syntax Python မှတ်ချက်များ Python Variables များ Python Data အမျိုးအစားများ Python နံပါတ်များ Python Casting Python ကြိုးများ Python Booleans Python အော်ပရေတာများ Python စာရင်းများ Python Tuples Python အစုံများ Python အဘိဓာန်များ Python If... Else Python while Loops Python For Loops Python လုပ်ဆောင်ချက်များ Python Lambda Python Arrays Python အတန်းများ/အရာဝတ္ထုများ Python Inheritance Python Iterators Python နယ်ပယ် Python Modules Python နေ့စွဲများ Python သင်္ချာ Python JSON Python RegEx Python PIP Python ကိုစမ်းကြည့်ပါ... ကလွဲရင် Python အသုံးပြုသူ ထည့်သွင်းမှု Python String Formatting

ဖိုင်ကိုင်တွယ်ခြင်း။

Python ဖိုင်ကို ကိုင်တွယ်ခြင်း။ Python ဖိုင်များကိုဖတ်ပါ။ Python ဖိုင်များကို ရေးသားခြင်း/ဖန်တီးပါ။ Python ဖိုင်များကိုဖျက်ပါ။

Python Modules

NumPy ကျူတိုရီရယ် Panda ကျင့်စဉ် Scipy ကျူတိုရီရယ်

Python Matplotlib

Matplotlib နိဒါန်း Matplotlib ကို စတင်လိုက်ပါ။ Matplotlib Pyplot Matplotlib Plotting Matplotlib အမှတ်အသားများ Matplotlib လိုင်း Matplotlib အညွှန်းများ Matplotlib Grid Matplotlib အပိုင်းခွဲများ Matplotlib ဖြန့်ကြဲခြင်း။ Matplotlib ဘားများ Matplotlib Histograms Matplotlib Pie ဇယားများ

စက်သင်ယူခြင်း။

စတင်အသုံးပြုခြင်း Mean Median Mode စံလွဲခြင်း။ ရာခိုင်နှုန်း ဒေတာဖြန့်ဝေခြင်း။ ပုံမှန်ဒေတာဖြန့်ဝေ ကွက်ကျားကွက်၊ Linear Regression Polynomial Regression Multiple Regression အတိုင်းအတာ ရထား/စမ်းသပ်မှု ဆုံးဖြတ်ချက်သစ်ပင်

Python MySQL

MySQL စတင်လိုက်ပါ။ MySQL ဒေတာဘေ့စ်ဖန်တီးပါ။ MySQL ဇယားဖန်တီးပါ။ MySQL ထည့်သွင်းခြင်း။ MySQL ကို ရွေးပါ။ MySQL ဘယ်မှာလဲ။ MySQL Order By MySQL ကိုဖျက်ပါ။ MySQL Drop Table MySQL အပ်ဒိတ် MySQL ကန့်သတ်ချက် MySQL Join

Python MongoDB

MongoDB စတင်လိုက်ပါ။ MongoDB ဒေတာဘေ့စ်ဖန်တီးပါ။ MongoDB သည် Collection ကိုဖန်တီးပါ။ MongoDB ထည့်သွင်းပါ။ MongoDB ကိုရှာပါ။ MongoDB မေးခွန်း MongoDB အမျိုးအစား MongoDB ကိုဖျက်ပါ။ MongoDB Drop Collection MongoDB အပ်ဒိတ် MongoDB ကန့်သတ်ချက်

Python အကိုးအကား

Python ခြုံငုံသုံးသပ်ချက် Python Built-in လုပ်ဆောင်ချက်များ Python String နည်းလမ်းများ Python စာရင်းနည်းလမ်းများ Python Dictionary Methods Python Tuple နည်းလမ်းများ Python သတ်မှတ်နည်းလမ်းများ Python ဖိုင်နည်းလမ်းများ Python သော့ချက်စာလုံးများ Python ခြွင်းချက်များ Python ဝေါဟာရ

Module အကိုးအကား

ကျပန်း Module တောင်းဆိုမှုများ Module Statistics Module သင်္ချာ မော်ဂျူး cMath မော်ဂျူး

Python လုပ်နည်း

စာရင်းပွားများကို ဖယ်ရှားပါ။ ကြိုးတစ်ချောင်းကို ပြောင်းပြန် နံပါတ်နှစ်ခုထည့်ပါ။

Python ဥပမာများ

Python ဥပမာများ Python Compiler Python လေ့ကျင့်ခန်းများ Python Quiz Python လက်မှတ်

Python RegEx


RegEx၊ သို့မဟုတ် ပုံမှန်ဖော်ပြချက်သည် ရှာဖွေမှုပုံစံတစ်ခုအဖြစ် ဖန်တီးထားသည့် ဇာတ်ကောင်များ၏ အတွဲတစ်ခုဖြစ်သည်။

စာကြောင်းတစ်ခုတွင် သတ်မှတ်ထားသော ရှာဖွေမှုပုံစံပါရှိမရှိ စစ်ဆေးရန် RegEx ကို သုံးနိုင်သည်။


RegEx မော်ဂျူး

rePython တွင် Regular Expressions နှင့် အလုပ်လုပ်ရန် အသုံးပြုနိုင်သည့် built-in package တစ်ခုရှိသည် ။

reမော်ဂျူး ကို တင်သွင်းပါ -

import re

Python တွင် RegEx

မော်ဂျူးကို သင် တင်သွင်းသောအခါ re၊ သင်သည် ပုံမှန်အသုံးအနှုန်းများကို စတင်အသုံးပြုနိုင်သည်-

ဥပမာ

"The" ဖြင့်စတင်ပြီး "စပိန်" ဖြင့်အဆုံးသတ်ခြင်းရှိမရှိကြည့်ရန် string ကိုရှာပါ-

import re

txt = "The rain in Spain"
x = re.search("^The.*Spain$", txt)

RegEx လုပ်ဆောင်ချက်များ

မော် reဂျူးသည် ကျွန်ုပ်တို့အား ကိုက်ညီမှုအတွက် စာကြောင်းတစ်ကြောင်းကို ရှာဖွေနိုင်စေမည့် လုပ်ဆောင်ချက်အစုံကို ပေးဆောင်သည်-

Function Description
findall Returns a list containing all matches
search Returns a Match object if there is a match anywhere in the string
split Returns a list where the string has been split at each match
sub Replaces one or many matches with a string


Metacharacters

Metacharacters များသည် အထူးအဓိပ္ပါယ်ရှိသော ဇာတ်ကောင်များဖြစ်သည်-

Character Description Example Try it
[] A set of characters "[a-m]"
\ Signals a special sequence (can also be used to escape special characters) "\d"
. Any character (except newline character) "he..o"
^ Starts with "^hello"
$ Ends with "planet$"
* Zero or more occurrences "he.*o"
+ One or more occurrences "he.+o"
? Zero or one occurrences "he.?o"
{} Exactly the specified number of occurrences "he{2}o"
| Either or "falls|stays"
() Capture and group    

အထူးအစီအစဉ်များ

အထူးအစီအစဥ်သည် \အောက်ဖော်ပြပါစာရင်းရှိ ဇာတ်ကောင်များထဲမှ တစ်ခု၏နောက်တွင် ပါရှိပြီး အထူးအဓိပ္ပါယ်ရှိသည်-

Character Description Example Try it
\A Returns a match if the specified characters are at the beginning of the string "\AThe"
\b Returns a match where the specified characters are at the beginning or at the end of a word
(the "r" in the beginning is making sure that the string is being treated as a "raw string")
r"\bain"
r"ain\b"

\B Returns a match where the specified characters are present, but NOT at the beginning (or at the end) of a word
(the "r" in the beginning is making sure that the string is being treated as a "raw string")
r"\Bain"
r"ain\B"

\d Returns a match where the string contains digits (numbers from 0-9) "\d"
\D Returns a match where the string DOES NOT contain digits "\D"
\s Returns a match where the string contains a white space character "\s"
\S Returns a match where the string DOES NOT contain a white space character "\S"
\w Returns a match where the string contains any word characters (characters from a to Z, digits from 0-9, and the underscore _ character) "\w"
\W Returns a match where the string DOES NOT contain any word characters "\W"
\Z Returns a match if the specified characters are at the end of the string "Spain\Z"

အစုံပါပဲ။

အတွဲတစ်ခုသည် အထူးအဓိပ္ပါယ်ရှိသော စတုရန်းကွင်းများအတွင်းမှ ဇာတ်ကောင်အစုအဝေးတစ်ခုဖြစ်သည် []-

Set Description Try it
[arn] Returns a match where one of the specified characters (a, r, or n) are present
[a-n] Returns a match for any lower case character, alphabetically between a and n
[^arn] Returns a match for any character EXCEPT a, r, and n
[0123] Returns a match where any of the specified digits (0, 1, 2, or 3) are present
[0-9] Returns a match for any digit between 0 and 9
[0-5][0-9] Returns a match for any two-digit numbers from 00 and 59
[a-zA-Z] Returns a match for any character alphabetically between a and z, lower case OR upper case
[+] In sets, +, *, ., |, (), $,{} has no special meaning, so [+] means: return a match for any + character in the string

 

findall() လုပ်ဆောင်ချက်

လုပ်ဆောင်ချက် သည် findall()ကိုက်ညီမှုအားလုံးပါဝင်သော စာရင်းကို ပြန်ပေးသည်။

ဥပမာ

ကိုက်ညီမှုအားလုံး၏စာရင်းကို ပရင့်ထုတ်ပါ။

import re

txt = "The rain in Spain"
x = re.findall("ai", txt)
print(x)

စာရင်းတွင် ၎င်းတို့တွေ့ရှိသည့် အစီအစဥ်အတိုင်း ကိုက်ညီမှုများပါရှိသည်။

ကိုက်ညီမှုမတွေ့ပါက၊ စာရင်းအလွတ်တစ်ခုကို ပြန်ပေးသည်-

ဥပမာ

တူညီမှုမတွေ့ပါက ဗလာစာရင်းကို ပြန်ပေးပါ။

import re

txt = "The rain in Spain"
x = re.findall("Portugal", txt)
print(x)

 

search() လုပ်ဆောင်ချက်

လုပ်ဆောင်ချက် သည် search()ကိုက်ညီမှုတစ်ခုအတွက် စာကြောင်းကို ရှာဖွေပြီး ကိုက်ညီမှု ရှိလျှင် တူညီသည့် အရာတစ်ခု ကို ပြန်ပေးသည်။

ပွဲစဉ်တစ်ခုထက်ပိုပါက၊ ပွဲ၏ပထမအကြိမ်မှသာလျှင် ပြန်လည်ရောက်ရှိပါမည်-

ဥပမာ

စာကြောင်းရှိ ပထမဆုံး နေရာလွတ် စာလုံးကို ရှာပါ-

import re

txt = "The rain in Spain"
x = re.search("\s", txt)

print("The first white-space character is located in position:", x.start())

ကိုက်ညီမှုမရှိပါက၊ တန်ဖိုးကို Noneပြန်ပေးသည်-

ဥပမာ

ကိုက်ညီမှုမရှိသော ရှာဖွေမှုကို ပြုလုပ်ပါ-

import re

txt = "The rain in Spain"
x = re.search("Portugal", txt)
print(x)

 

split() လုပ်ဆောင်ချက်

လုပ်ဆောင်ချက် သည် split()ကိုက်ညီမှုတစ်ခုစီတွင် စာကြောင်းခွဲပြီးသည့်စာရင်းကို ပြန်ပေးသည်-

ဥပမာ

နေရာလွတ် အက္ခရာတစ်ခုစီတွင် ခွဲထားသည်-

import re

txt = "The rain in Spain"
x = re.split("\s", txt)
print(x)

ပါရာမီတာ ကို သတ်မှတ်ခြင်းဖြင့် သင်သည် ဖြစ်ပွားမှုအရေအတွက်ကို ထိန်းချုပ်နိုင်သည် maxsplit -

ဥပမာ

ပထမအကြိမ်တွင်သာ string ကို ခွဲပါ-

import re

txt = "The rain in Spain"
x = re.split("\s", txt, 1)
print(x)

 

sub() လုပ်ဆောင်ချက်

sub()လုပ်ဆောင်ချက်သည် ကိုက်ညီမှုများကို သင်ရွေးချယ်သော စာသားဖြင့် အစားထိုးသည် -

ဥပမာ

နေရာလွတ် အက္ခရာတိုင်းကို နံပါတ် 9 ဖြင့် အစားထိုးပါ။

import re

txt = "The rain in Spain"
x = re.sub("\s", "9", txt)
print(x)

ကန့်သတ်ချက်များ သတ်မှတ်ခြင်းဖြင့် အစားထိုးမှုအရေအတွက်ကို သင်ထိန်းချုပ်နိုင်သည် count -

ဥပမာ

ပထမအကြိမ် ၂ ခုကို အစားထိုးပါ။

import re

txt = "The rain in Spain"
x = re.sub("\s", "9", txt, 2)
print(x)

 

အရာဝတ္ထုကို ယှဉ်ပါ။

Match Object သည် ရှာဖွေမှုနှင့် ရလဒ်ဆိုင်ရာ အချက်အလက် ပါဝင်သော အရာဝတ္ထုတစ်ခု ဖြစ်သည်။

မှတ်ချက်- ကိုက်ညီမှုမရှိပါက၊ NoneMatch Object အစား တန်ဖိုးကို ပြန်ပေးပါမည်။

ဥပမာ

Match Object ကို ပြန်ပေးမည့် ရှာဖွေမှုကို ပြုလုပ်ပါ-

import re

txt = "The rain in Spain"
x = re.search("ai", txt)
print(x) #this will print an object

Match object တွင် ရှာဖွေမှုနှင့် ပတ်သက်သော အချက်အလက်များကို ရယူရန် အသုံးပြုသည့် ဂုဏ်သတ္တိများနှင့် နည်းလမ်းများ ရှိပြီး ရလဒ်-

.span()ပွဲ၏ start- နှင့် end position များပါရှိသော tuple တစ်ခုကို ပြန်ပေးသည်။
.stringfunction ထဲသို့ ဖြတ်သွားသော string ကို
.group()return ပြန်သည် ၊ match ရှိခဲ့သည့် string ၏ အစိတ်အပိုင်းကို ပြန်ပေးသည်

ဥပမာ

ပထမပွဲဖြစ်ပွားမှု၏ အနေအထား (အစ-နှင့် အဆုံး-အနေအထား) ကို ပရင့်ထုတ်ပါ။

ပုံမှန်အသုံးအနှုန်းသည် စာလုံးကြီး "S" ဖြင့် စတင်သည့် မည်သည့်စကားလုံးကိုမဆို ရှာဖွေသည်-

import re

txt = "The rain in Spain"
x = re.search(r"\bS\w+", txt)
print(x.span())

ဥပမာ

လုပ်ဆောင်ချက်ထဲသို့ ဖြတ်သွားသော စာကြောင်းကို ပရင့်ထုတ်ပါ-

import re

txt = "The rain in Spain"
x = re.search(r"\bS\w+", txt)
print(x.string)

ဥပမာ

ကိုက်ညီမှုရှိသည့် စာတန်း၏အပိုင်းကို ပရင့်ထုတ်ပါ။

ပုံမှန်အသုံးအနှုန်းသည် စာလုံးကြီး "S" ဖြင့် စတင်သည့် မည်သည့်စကားလုံးကိုမဆို ရှာဖွေသည်-

import re

txt = "The rain in Spain"
x = re.search(r"\bS\w+", txt)
print(x.group())

မှတ်ချက်- ကိုက်ညီမှုမရှိပါက၊ NoneMatch Object အစား တန်ဖိုးကို ပြန်ပေးပါမည်။