re例子,僅供參考
import re
匹配字串
# pattern = re.compile(r'hello')
# match = pattern.search('ni hello cxy61!') #全字元匹配字串 .search()
# search = pattern.match('ai hello') #只在開頭匹配字串 .match()
# if match:
# print(match.group())
# else:
# print('no match.')
#
# if search:
# print(search.group())
# else:
# print('no search')
替換
time = '2017-10-01'
pattern = re.compile(r'\D') #匹配非數字的字元
sub = pattern.sub('/',time) #替換非數字的字元
print(sub)
print(re.sub(r'\D','/',time)) #也可以這樣寫,re.sub(表示式,替換字元,內容)
#\D非數字的,'/'替換字元,time目標;把time裡面非數字的都替換為/
相關推薦
re例子,僅供參考
import re匹配字串# pattern = re.compile(r'hello')# match = pattern.search('ni hello cxy61!') #全字元匹配字串 .search()# search = pattern.match('ai hello') #只在開頭匹配字串
簡單java反射,小例子,僅供參考
package test; public class c { public String cc(String name,String addr){ return "My name is "+nam
leetcode35題:搜索插入位置(不是最優解法,僅供參考)
重復 mce 僅供參考 sea elf () 參考 lis 位置 給定一個排序數組和一個目標值,在數組中找到目標值,並返回其索引。如果目標值不存在於數組中,返回它將會被按順序插入的位置。你可以假設數組中無重復元素。 示例 1:輸入: [1,3,5,6], 5輸出: 2示例
基於MSP430F5529的超聲波測距原始碼,自己寫的可能不對,僅供參考
超聲波的原理大家百度一下就應該知道了,因此基於MSP430的超聲波主要是調整時鐘就行了。 程式碼如下 #include "msp430f5529.h" #include "usart.h" #include "stdio.h" double a = 1.111;
Android 圖片資原始檔命名規範(非官方,僅供參考)
對於Android的資原始檔的命名,Google官方並沒有提供統一的規範,民間的命名方式可謂是百花齊放、相容幷包,比較知名的有阿里巴巴開發規範,以及Blankj的AndroidStandardDevelop,以下內容是筆者參考了其他的一些命名規範,加上自己總結的一些命名方式所得。由於專
AG視訊實戰穩下分技巧大分享,僅供參考
AG視訊怎麼玩。網止【8d9a。c 0 M】下面我來告訴大家怎麼玩才能玩好, 技巧1不盲目打 不論你用什麼打法、什麼路、什麼式纜……,連負幾百口也不是完全不可能。平注連shu十幾口已經很心淡了,居然還有人用負追纜法,久du下去負追纜絕對不是明智的方法技巧2命中率:如何提高命中率,這無疑是每位BJL玩家都想
[程式設計挑戰]彩色石子,僅供參考
public class ColoredStoneTest { /** * @param args * 有一行彩色的棋子,每個棋子的顏色是k種顏色之一。 * 你不能改變棋子的順序,但是可以移走一些棋子。 * 問至少移走多少個石子,才能使得兩個同色的石子之間沒有其他顏色的
[程式設計挑戰]交替字串,僅供參考
package com.zq.challenge; /** * 如果字串str3能夠由str1和str2中的字元按順序交替形成,那麼稱str3為str1和str2的交替字串。 * 例如str1="abc",str2="def",那麼"adbecf", "abcdef", "abdecf", "
一個JNI建立日期物件的例子,僅作參考
JNIEXPORT void JNICALL Java_com_cjz_mapscr_MapScreen_drawLines (JNIEnv *env, jobject thiz) { jclass clazz_date = (*env)->FindClass(env, "java/util
哨兵2資料‘檔名’詳解(吐血整體,僅供參考)
哨兵2資料檔名詳解 Sentinel-2 Level-1C products: (2016年12月6日之後生成的Sentinel-2 Level-1C產品的新格式命名約定) .zip解壓後為.SAFE檔案 S2A_MSIL1C_20170105T013442_
一個完整的BDC程式,僅供參考!(包括各種引數的配置)
BDC的引數我們都比較熟悉了:可能有一個opt我們用得比較少,而且經常有問題的時候我們還需要F1去檢視是否有辦法可以解決。(例如由於commit work導致沒有返回message的) LOOP AT IT_BDC. PERFORM bdc_dynpro U
幾種開源SIP協議棧對比(文章很早了,僅供參考)
幾種開源SIP協議棧對比 2006-12-05 15:49 基於SIP的開發的話,基本還是使用開源的協議棧的,當然也有牛的公司和單位是自己開發協議棧的,不過並不一定比開源的好用,不過可能使用在特定場合時,會有一定優勢吧。 在以前開發UA時,我用的
CSS檔案和樣式命名規範,僅供參考
id一個頁面只可以使用一次,class可以多次引用。 我在頁面中用了多個相同id在IE中顯示也正常,id和class好象沒什麼區別,用多個相同id有什麼影響嗎? 頁面存在多個相同的ID影響就是不能通過W3的校驗。 在頁面顯示上,目前的瀏覽器還都允許你犯這個錯誤,用多個相同ID“一般情況下”也能正常顯示。但是
基於SpirngMVC登入攔截器(使用了redis快取),僅供參考
package com.avic.common.interceptor; import java.io.IOException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException;
百度搜索下拉框效果(鍵盤操作)只完成部分功能,僅供參考
<script src="../scripts/jquery-2.1.1.min.js"></script> <script type="text/javascript"> $(function () {
建算數表示式樹並計算(應付作業,僅供參考)
只是為了應付資料結構老師佈置的作業,算式裡的數只能是整數: 例如輸入 (6+3)*(4-2)*(41-1) 輸出 720.00 #include <stdio.h> #include <string.h> const int N = 1000; i
Junit4 三角形測試例子,供初學者借鑑(僅供參考)
本人在初步學到Junit4 時,用簡單的三角形作為demo,以下是詳細程式碼: Triangle.java 檔案 程式碼 /** * 三角形問題實現 * 給定三條邊,判斷三角形的形狀 * @author zhouxin * */ public class Tri
【學海無涯---那山那水那人】學海無涯,從放棄到開始...贈人玫瑰,手有餘香,感悟人生,感悟自己,當“你”真正看到我的時候,也許就是緣分的開始...如有侵權雷同,請留言博主刪除,博主的文章也可轉載,請註明出處,僅供個人學習參考,謝謝
學海無涯,從放棄到開始...贈人玫瑰,手有餘香,感悟人生,感悟自己,當“你”真正看到我的時候,也許就是緣分的開始...如有侵權雷同,請留言博主刪除,博主的文章也可轉載,請註明出處,僅供個人學習參考,謝...
免費資源網站,僅供學習參考
網盤類: 推薦 去轉盤: http://www.quzhuanpan.com Bdsola: http://www.3134.cc 西林街: http://www.x
ab壓測引數化,可以同時執行多條,指令碼僅供參考
#!/bin/bash echo '*==========================================================*' echo '| 本指令碼工具基於ab(Apache benchmark),請先安裝好ab, awk |' e